﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Google.YouTube;

namespace YoutubeGetterV2
{
	/// <summary>
	/// Interaction logic for Login.xaml
	/// </summary>
	public partial class Login : Window
	{
		public Login()
		{
			DataContext = this;
			InitializeComponent();
		}

		public String UserName
		{
			get { return (String)GetValue(UserNameProperty); }
			set { SetValue(UserNameProperty, value); }
		}
		public static readonly DependencyProperty UserNameProperty =
			DependencyProperty.Register("UserName", typeof(String), typeof(Login), new UIPropertyMetadata(""));

		public void CanLogin(object sender, CanExecuteRoutedEventArgs e)
		{
			e.CanExecute = !String.IsNullOrEmpty(UserName);
		}

		public void DoLogin(object sender, RoutedEventArgs e)
		{
			YouTubeRequestSettings settings = new YouTubeRequestSettings("YoutubeGetter", YoutubeTools.developerKey, UserName, PasswordBox.Password);
			YouTubeRequest request = new YouTubeRequest(settings);
			YoutubeTools.request = request;
			this.Close();
		}

		public void CloseForm(object sender, RoutedEventArgs e)
		{
			this.Close();
		}
	}
}
